home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / TOOLBOX.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  101 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.4  $
  6. //
  7. // Definition of class TToolBox.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_TOOLBOX_H)
  10. #define OWL_TOOLBOX_H
  11.  
  12. #if !defined(OWL_GADGETWI_H)
  13. # include <owl/gadgetwi.h>
  14. #endif
  15.  
  16. #if defined(BI_NAMESPACE)
  17. namespace OWL {
  18. #endif
  19.  
  20. // Generic definitions/compiler options (eg. alignment) preceeding the 
  21. // definition of classes
  22. #include <services/preclass.h>
  23.  
  24. //
  25. // class TToolBox
  26. // ~~~~~ ~~~~~~~~
  27. // Arranges its gadgets in a matrix. All columns are the same width (as wide
  28. // as the widest gadget) and all rows are the same height (as high as the
  29. // heighest gadget)
  30. //
  31. // You specify the number of rows and columns you want. You can specify
  32. // AS_MANY_AS_NEEDED in which case the toolbox figures out how many rows or
  33. // columns are needed based on the opposite dimension (e.g. if there are
  34. // 20 gadgets and you requested 4 columns then you would get 5 rows)
  35. //
  36. const int AS_MANY_AS_NEEDED = -1;
  37.  
  38. class _OWLCLASS TToolBox : public TGadgetWindow {
  39.   public:
  40.     TToolBox(TWindow*        parent,
  41.              int             numColumns = 2,
  42.              int             numRows = AS_MANY_AS_NEEDED,
  43.              TTileDirection  direction = Horizontal,  // Row Major
  44.              TModule*        module = 0);
  45.  
  46.     void  GetDesiredSize(TSize& size);
  47.     void  LayoutSession();
  48.  
  49.     // Override Insert member function and tell the button to not notch
  50.     // its corners
  51.     //
  52.     void  Insert(TGadget& gadget, TPlacement = After, TGadget* sibling = 0);
  53.  
  54.     virtual void  SetDirection(TTileDirection direction);
  55.  
  56.   protected:
  57.     TRect TileGadgets();
  58.  
  59.     int   GetNumRows() const;
  60.     int   GetNumColumns() const;
  61.  
  62.   protected_data:
  63.     int   NumRows;
  64.     int   NumColumns;
  65.  
  66.   private:
  67.     void  ComputeNumRowsColumns(int& numRows, int& numColumns);
  68.     void  ComputeCellSize(TSize& size);
  69.  
  70.   DECLARE_CASTABLE;
  71. };
  72.  
  73. // Generic definitions/compiler options (eg. alignment) following the 
  74. // definition of classes
  75. #include <services/posclass.h>
  76.  
  77. #if defined(BI_NAMESPACE)
  78. } // namespace OWL
  79. #endif
  80.  
  81. //----------------------------------------------------------------------------
  82. // Inline implementation
  83. //
  84.  
  85. //
  86. // Return the number of rows the toolbox is using.
  87. //
  88. inline int TToolBox::GetNumRows() const
  89. {
  90.   return NumRows;
  91. }
  92.  
  93. //
  94. // Return the number of columns the toolbox is using.
  95. //
  96. inline int TToolBox::GetNumColumns() const
  97. {
  98.   return NumColumns;
  99. }
  100. #endif  // OWL_TOOLBOX_H
  101.